//
//  EmailViewController.m
//  盘盈贷
//
//  Created by iOS on 15/3/26.
//  Copyright (c) 2015年 Yunpeng Technologies. All rights reserved.
//

#import "EmailViewController.h"
#import "APIRequest.h"
@interface EmailViewController ()
{
    UITextField *email;
    UILabel *address;
    
    
}
@end

@implementation EmailViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        self.title = @"邮箱认证";
        
        self.view.backgroundColor = [UIColor whiteColor];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    CGFloat height = self.view.frame.size.height;
    CGFloat width = self.view.frame.size.width;
    
    UILabel *youxianghao = [[UILabel alloc] initWithFrame:CGRectMake(10, height / 7, 70, 30)];
    youxianghao.text = @"邮箱号 :";
    [self.view addSubview:youxianghao];
    [youxianghao release];
    
//    address = [[UITextField alloc] initWithFrame:CGRectMake(10, height / 4.8, 230, 40)];
//    address.center = CGPointMake(160, height / 4.3);
//    address.placeholder = @"绑定邮箱地址";
//    address.textColor = [UIColor grayColor];
//    address.borderStyle = UITextBorderStyleRoundedRect;
//    address.clearButtonMode = UITextFieldViewModeWhileEditing;
//    address.borderStyle = UITextBorderStyleLine;
//    [self.view addSubview:address];
//    [address release];
    
    address = [[UILabel alloc] initWithFrame:CGRectMake(10, height / 4.8, 230, 40)];
    address.center = CGPointMake(160, height / 4.3);
    address.text = @"请到PC端绑定邮箱 ";
    [self.view addSubview:address];
    [address release];
    
//    email = [[UITextField alloc] initWithFrame:CGRectMake(7, height / 3, 140, 40)];
//    email.center = CGPointMake(110, height / 3);
//    email.placeholder = @"邮箱验证码";
//    email.textColor = [UIColor grayColor];
//    email.borderStyle = UITextBorderStyleRoundedRect;
//    email.clearButtonMode = UITextFieldViewModeWhileEditing;
//    email.borderStyle = UITextBorderStyleLine;
//    [self.view addSubview:email];
//    [email release];
//    
//   
//    UIButton *test = [UIButton buttonWithType:UIButtonTypeSystem];
//    test.frame = CGRectMake(200, height / 3, width / 4, 40);
//    test.center = CGPointMake(235, height / 3);
//    [test setTitle:@"获取验证码" forState:UIControlStateNormal];
//    test.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
//    test.backgroundColor = [UIColor redColor];
//    [test setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [test addTarget:self action:@selector(test:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:test];
//    
//    
//    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
//    button.frame = CGRectMake(width / 2.1, height / 2.3, width / 1.4, 40);
//    button.center = CGPointMake(width / 2.1, height / 2.3);
//    button.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
//    [button setTitle:@"下一步" forState:UIControlStateNormal];
//    button.backgroundColor = [UIColor redColor];
//    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [button addTarget:self action:@selector(next:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:button];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(removeKeyboard)];
    [self.view addGestureRecognizer:tap];
    
    
    
}
-(void)removeKeyboard{
    [email resignFirstResponder];
}
- (void)test:(id)sender {
    NSString *str = [NSString stringWithFormat:@"http://www.cloudpeng.com:8102/account/PostChangeEmail?strusername=%@&newemail=%@", self.name, email.text];
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
    [manager GET:str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSString *ss = [[responseObject firstObject] objectForKey:@"value"];
        email.text = ss;
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"~~~~~~~%@",error);
    }];
    NSLog(@"name:%@", self.name);
    NSLog(@"email:%@", email.text);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
